<!doctype html>
<html lang="en">
{include file='public/header'}
<body class="login-bg">
    
    <div class="login layui-anim layui-anim-up">
        <div class="message">小视频-管理注册</div>
        <div id="darkbannerwrap"></div>
        
        <form method="post" class="layui-form" >
            <input name="username" placeholder="用户名"  type="text" lay-verify="required" class="layui-input" >
            <hr class="hr15">
            <input name="password" id="password" lay-verify="pass" placeholder="密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input name="password1" id="password1" lay-verify="repass" placeholder="确认密码"  type="password" class="layui-input">
            <hr class="hr15">
            <input value="注册" lay-submit lay-filter="login" style="width:100%;" type="submit">
            <hr class="hr20" >
            <span onclick="reg()"  style="width:100%;" class="layui-btn layui-btn-normal">已注册,返回登陆</span>
        </form>
    </div>

    <script>
        layui.use('form', function(){
            var form = layui.form;
            form.verify({
                pass: [/(.+){6,12}$/, '密码必须6到12位']
                ,repass: function(value){
                    if($('#password').val()!=$('#password1').val()){
                        return '两次密码不一致';
                    }
                }
            });
            //监听提交
            form.on('submit()', function(data){
                $.ajax({
                    url: '{:url("admin/login/register")}'
                    , data: data.field
                    , type: "post"
                    , dataType: "json"
                    , success: function (e) {
                        if (e.code===200) {
                            layer.msg('恭喜你，注册成功!',{icon:1,time:2000},function () {
                                location.href='{:url("admin/index/index")}';
                            });
                        } else {
                             layer.msg(e.msg,{icon:5,time:2000});
                        }
                    }
                });
                return false;
            });
         });

        function reg() {
            location.href='{:url("admin/login/index")}';
        }
    </script>

</body>
</html>